import axios from "axios"
import {Toast} from "antd-mobile"
const instance = axios.create({
});

//请求的拦截
//config:请求的配置信息
instance.interceptors.request.use(function(config){
  // Do something before request is sent
  Toast.loading("正在加载",0,null,true);
  //Toast.loading(提示内容,自动关闭的延时/单位秒,关闭后回调,是否显示透明蒙层，防止触摸穿透)
  return config;
},function(error){
  // Do something with request error
  return Promise.reject(error);
});

//响应的拦截
instance.interceptors.response.use(function(response){
  // Do something with response data
  Toast.hide();
  return response
},function(error){
  // Do something with response error
  return Promise.reject(error)
})

export default instance;